package com.howard.webapp.familymanagement.repository;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.howard.webapp.familymanagement.domain.User;


public interface UserRepository extends BaseRepository<User, Long>{
	
	/**
	 * 根据方法名解析
	 * @param loginId
	 * @return
	 */
	List<User> findByLoginId(String loginId);
	
	/**
	 * 根据@Query和命名参数解析
	 * 注意这里是HSQL，所以用User(而非T_user)
	 * @param name
	 * @return
	 */
	@Query(" from User u where u.name = :name")
	public List<User> findByName(@Param("name") String name);

	/**
	 * 根据@Query和占位符解析
	 * @param livingAddr
	 * @return
	 */
	@Query(" from User u where u.livingAddr = ?1")
	List<User> findByLivingAddr(String livingAddr);
	
	@Query(" from User u")
	List<User> findAllWithPage(Pageable pageRequest);
	
}